package org.zoffy.commons;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class BaseResponse<T> {
    private Integer code;
    private String msg;
    private T data;
    private static <T> BaseResponse<T> result(int code, String msg, T data) {
        return new BaseResponse<T>(code, msg, data);
    }
    private static <T> BaseResponse<T> result(StatusCode statusCode, T data) {
        return BaseResponse.result(statusCode.getCode(),statusCode.getMsg(),data);
    }
    public static <T> BaseResponse<T> success(T data) {
        return BaseResponse.result(StatusCode.SUCCESS,data);
    }
    public static <T> BaseResponse<T> success() {
        return BaseResponse.result(StatusCode.SUCCESS,null);
    }
    public static <T> BaseResponse<T> failure() {
        return BaseResponse.result(StatusCode.UNKNOWN_EXCEPTION,null);
    }
}
